/* 
 * File:   Operateur.h
 * Author: Gab'z
 *
 * Created on 8 mai 2012, 02:23
 */

#ifndef OPERATEUR_H
#define	OPERATEUR_H

#include "Pile.h"
#include "operator_exception.h"
#include "CalcObjet.h"
#include <algorithm>
#include "Calculatrice.h"

class Operateur : public CalcObjet {
public:
    const std::string& getName() const;
    std::string toString() const;

    void execute(Pile* pile) const throw (OperatorException) {
        try {
            exec(pile);
        } catch (OperatorException e) {
            throw OperatorException(e.what());
        }
    }
    virtual ~Operateur();

protected:
    std::string _name;

    Operateur(const std::string & name) {
        std::string str = std::string(name);
        std::transform(str.begin(), str.end(), str.begin(), ps_toupper());
        _name = str;
    }

private:

    virtual void exec(Pile * pile) const throw (OperatorException) = 0;
};

#endif	/* OPERATEUR_H */

